package com.itheima;

import org.apache.commons.collections4.SetValuedMap;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * @author wmh
 * @version 1.0 2022/5/25
 * @Description: POI测试类
 * 创建一个低版本的Excel并且向单元格添加数据
 **/
//@RunWith(SpringRunner.class)
//@SpringBootTest
public class POIDemo {


    public static void main(String[] args) throws Exception {
        //1.创建一个全新工作簿
        Workbook workbook = new HSSFWorkbook();
        //2.在工作簿中创建新的工作表
        Sheet sheet = workbook.createSheet("POI操作");
        //3.在工作表中创建行-行的脚标
        Row row = sheet.createRow(0);
        //4.在行中创建单元格-单元格脚标
        Cell cell = row.createCell(0);
        //5.在单元格写入内容
        cell.setCellValue("第一行第一列的单元格数据");
        workbook.write(new FileOutputStream(new File("D:/test.xls")));
        workbook.close();
    }

}